#ifndef  _TC_MAN_H_
#define  _TC_MAN_H_

#include "../define/define.h"
#include "../util/lock.h"
#include "tcp_client.h"

class tc_thread;

struct tcp_node
{
    tcp_client*  s_socket;
    uint32       d_ip;
	uint16       d_port;
	uint16       l_port;
};

class  tc_sink
{
public:
	virtual bool OnRead(uint32 socket,char* buf, uint32 buf_size) = 0;
	virtual bool OnError(uint32 socket) = 0;
	virtual bool OnBuffer(uint32 socket) = 0;
	virtual bool OnSend() = 0;
};

class tc_man 
{
public:
	tc_man(tc_sink* sink);
	~tc_man();

	bool  add_socket(uint32* socket,ip_node task);
	bool  del_socket(uint32 socket);

	int   send_buf(uint32 socket,char* buf, uint32 buf_size);
		
private:

	std::map<uint32,tcp_node*>  m_nodemap;	

	tc_thread*          m_thread;	
	
	tc_sink*            m_sink;
	logfile*            m_log;
	lock                m_lock;
};

#endif
